Socket
Socket
Sign inDemoInstall

rqlite-fp

Package Overview
Dependencies
54
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rqlite-fp

A client library for rqlite in function programming style


Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

rqlite-fp

Build Status David DM GitHub code size in bytes GitHub package.json version GitHub

A client library for rqlite in a functional programming style

Installation

npm install --save rqlite-fp

Example

With promises

const rqlite = require('rqlite-fp/promises');

(async function () {
  const connection = await connect('http://localhost:4001')
  const tableCreated = await execute(connection, 'CREATE TABLE lorem (info TEXT)')
  const testResults = await getAll(connection, 'SELECT * FROM test')

  console.log(results)
}())

With callbacks

const connect = require('rqlite-fp/connect')
const execute = require('rqlite-fp/execute')
const getAll = require('rqlite-fp/getAll')

function getTestRecords (callback) {
  connect('http://localhost:4001', function (error, connection) {
    if (error) { return callback(error) }
    execute(connection, 'CREATE TABLE lorem (info TEXT)', function (error, tableCreated) {
      if (error) { return callback(error) }
      getAll(connection, 'SELECT * FROM test', function (error, testResults) {
        if (error) { return callback(error) }
        callback(null, testResults)
      })
    })
  })
}

getTestRecords(function (error, testRecords) {
  if (error) {
    throw error
  }
  console.log(testRecords)
})

With righto

const righto = require('righto')
const connect = require('rqlite-fp/connect')
const execute = require('rqlite-fp/execute')
const getAll = require('rqlite-fp/getAll')

const connection = righto(connect, 'http://localhost:4001')
const tableCreated = righto(execute, connection, 'CREATE TABLE lorem (info TEXT)')
const testResults = righto(getAll, connection, 'SELECT * FROM test', righto.after(tableCreated))

testResults(function (error, results) {
  if (error) {
    throw error
  }

  console.log(results)
})

Functions signatures

start -> {httpAddr, raftAddr, join} -> (error, connection)

connect -> filename -> [mode] -> (error, connection)

run -> connection -> sql -> [parameters] -> (error, result={lastId, changes})

getAll -> connection -> sql -> (error, rows)

getOne -> connection -> sql -> (error, row)

batch -> connection -> sql -> [[parameters]] -> (error, result={lastId, changes})

execute -> connection -> sql -> (error, connection)

close -> connection -> (error)

License

This project is licensed under the terms of the MIT license.

Keywords

FAQs

Last updated on 13 Aug 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc